﻿<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="1024招聘" />
    <!-- 作者 -->
    <meta name="revised" content="1024招聘.v3, 2019/05/01" />
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介" />
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
    <title>1024招聘</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="../../css/base.css">
    <link rel="stylesheet" type="text/css" href="../../fonts/iconfont.css">
    <script type="text/javascript" src="../../framework/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../../layui/css/layui.css">
    <script type="text/javascript" src="../../layui/layui.js"></script>
    <script src="../../framework/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->

    <style>

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-form {
            margin-right: 30%;
        }
    </style>

</head>

<body>
    <div class="cBody">
        <form id="addForm" class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">图片名称</label>
                <div class="layui-input-block">
                    <input id="PicName" type="text" name="goodsName" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">上传图片</label>
                <div class="layui-upload-drag" id="goodsPic">
                    <img id="Imgs" src="#" alt="Alternate Text" style="display:none" />
                    <i class="layui-icon"></i>
                    <p>点击上传，或将文件拖拽到此处</p>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea id="Remark" name="desc" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">图片类型</label>
                <div class="layui-input-block">
                    <select id="ImgTypeId" class="select Competence_sort col-xs-6 col-lg-6 " name="admin-role" size="1" id="Competence_sort">
                        <option value="0">--图片类型--</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select id="Status" class="select Competence_sort col-xs-6 col-lg-6 " name="admin-role" size="1" id="Competence_sort">
                        <option value="0">--状态筛选--</option>
                        <option value=true>true</option>
                        <option value=false>false</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <div id="Update" class="layui-btn" lay-submit lay-filter="submitBut">修改</div>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>


        <script>
            //上传logo
            layui.use(['upload', 'layer', 'jquery'], function () {
                var $ = layui.jquery,
                    layer = layui.layer,
                    upload = layui.upload;

                //拖拽上传
                upload.render({
                    elem: '#goodsPic'
                    , headers: { token: 'sasasas' }
                    , url: "/FileUpload/UploadImage"
                    , before: function (obj) {
                        //预读本地文件示例，不支持ie8
                        obj.preview(function (index, file, result) {

                            $("#goodsPic>img").attr("src", result);
                            $("#goodsPic>img").show();
                            $("#goodsPic>i").hide();
                            $("#goodsPic>p").hide();
                        });
                    }
                    , done: function (res) {
                        //如果上传失败
                        if (res.code > 0) {
                            return layer.msg('上传失败');
                        } else {

                            $("#goodsPic>img").attr("src", res.Url);
                            return layer.msg('上传成功');
                            //return layer.msg(res.data.Data.Path);路径
                        }
                        //上传成功
                    }
                    , error: function () {
                        //演示失败状态，并实现重传
                        var demoText = $('#test10');
                        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                        demoText.find('.demo-reload').on('click', function () {
                            uploadInst.upload();
                        });
                    }
                })
            })
        </script>
        <script>
            $("#Update").click(function () {
                var data = {};
                data.PicName = $("#PicName").val();
                data.Src = $("#Imgs").attr("src");
                data.Remark = $("#Remark").val();
                data.TypeId = $("#ImgTypeId").val();
                data.Status = $("#Status").val();
                $.ajax({
                type:"post",
                url: "/Picture/UpdatePictureInfo",
                data: data,
                success: function (json) {
                    if (json.Success) {
                        layer.alert('修改成功！', {
                            title: '提示框',
                            icon: 1,
                        }, function () {
                            location.href = "/Picture/PictureManager";
                            });

                    } else {
                        layer.alert('修改失败！', {
                            title: '提示框',
                            icon: 0,
                        });
                        //layer.close(MenuSection);
                    }
            }
            });
            })
        </script>
    </div>
</body>

</html>